﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using EDIConsole;
using System.Threading;


namespace EDIService
{
	public partial class EDIService : ServiceBase
	{
		public EDIService()
		{
			InitializeComponent();
		}

		protected override void OnStart(string[] args)
		{
            PrjProperty.Itit();
            PrjProperty.Logs.WriteLogs("Запуск службы.  Версия: " + PrjProperty.Version);
            
            PrjProperty.Logs.WriteLogs("IsCanReadTaskDir: " + PrjProperty.IsCanReadTaskDir.ToString());
            PrjProperty.Logs.WriteLogs(DateTime.Now.ToString());
			PrjProperty.Logs.WriteLogs("Чтение параметров params.xml");
			PrjProperty.LoadConfig("params.xml");
			PrjProperty.Logs.WriteLogs("Параметры прочитаны, имя клиента: " + PrjProperty.ClientName);
			//PrjProperty.SaveXMLParam("params.xml");

			Console.WriteLine("Creating timer: {0}\n",
				DateTime.Now.ToString("h:mm:ss"));

			Timer timerReadTaskDir = new Timer(PrjProperty.ReadTaskDir, null, 0, 1000);
            PrjProperty.Logs.WriteLogs("timerReadTaskDir: " + timerReadTaskDir.ToString());
			Timer timerRunTask = new Timer(PrjProperty.RunTask, 5, 0, 2000);

		}

		protected override void OnStop()
		{
			PrjProperty.Logs.WriteLogs("Остановка службы");
		}

		
	}
}
